class NumArray {
private:
    vector<int> dict;
public:
    NumArray(vector<int>& nums) {
        int sum;
        dict.push_back(0);
        for(int i=0;i<nums.size();i++){
            sum=0;
            for(int j=0;j<=i;j++){
                sum+=nums[j];
            }
            //cout<<sum<<endl;
            dict.push_back(sum);
        }
    }
    
    int sumRange(int i, int j) {
        return dict[j+1]-dict[i];
    }
};

class NumArray {
private:
    vector<int> dict;
public:
    NumArray(vector<int>& nums) {
        dict.push_back(0);
        for(int i=0;i<nums.size();i++){
            //cout<<sum<<endl;
            dict.push_back(nums[i]+dict[dict.size()-1]);
        }
    }
    
    int sumRange(int i, int j) {
        return dict[j+1]-dict[i];
    }
};